
const mysql = require('mysql')
let connObj = mysql.createConnection({
    host: '127.0.0.1',
    user: 'root',
    password: 'root',
    port: 3306,
    database: 'stu'
})

function myQuery(sql=''){
    return new Promise((resolve, reject) => {
        connObj.query(sql, (err, result) => { 
           resolve({ err,result }) 
        })
    })

}

module.exports = myQuery


// 以下就是你具体业务中的样式代码 
// async function myDemo(){

//     let sql = ` SELECT * FROM students WHERE username="李四"`
//     let res1 = await myQuery(sql )
//     console.log( res1,'拿到了结果' )
// }
// myDemo()